package com.example.test.dialogfactory;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.startup.Initializer;
import com.example.test.dialogfactory.Provider.InitHolder;
import easier.log.logger.Logger;
import java.util.ArrayList;
import java.util.List;

/**
 * 1. implementation "androidx.startup:startup-runtime:1.1.1"
 * 2. 实现Initializer
 * 3.  <provider
 * android:name="androidx.startup.InitializationProvider"
 * android:authorities="${applicationId}.androidx-startup"
 * android:exported="false"
 * tools:node="merge">
 * <meta-data
 * android:name="com.example.test.dialogfactory.Provider"
 * android:value="androidx.startup" />
 * </provider>
 */
public class Provider implements Initializer< InitHolder > {

    @NonNull
    @Override
    public InitHolder create( @NonNull Context context ) {

        return new InitHolder( context );
    }

    @NonNull
    @Override
    public List< Class< ? extends Initializer< ? > > > dependencies() {

        return new ArrayList<>();
    }

    public static class InitHolder {

        private Context mContext;

        public InitHolder( Context context ) {

            mContext = context;

            Logger.d( "InitHolder create: " + mContext );
        }
    }
}
